//
//  HMHeMaiViewController.m
//  网易彩票01
//
//  Created by Macx on 16/2/21.
//  Copyright © 2016年 Macx. All rights reserved.
//

#import "HMHeMaiViewController.h"
#import "HMTitleBtn.h"
@interface HMHeMaiViewController ()
@property(nonatomic,strong)UIView *menuView;
@end

@implementation HMHeMaiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (IBAction)titleBtnClick:(HMTitleBtn *)titleBtn {
    [UIView animateWithDuration:0.25 animations:^{
        titleBtn.imageView.transform=CGAffineTransformEqualToTransform(CGAffineTransformIdentity,titleBtn.imageView.transform)?CGAffineTransformMakeRotation(-M_PI):CGAffineTransformIdentity;
    }];
    
    
    
    
    
   //isDescendantOfView用与判断一个view是不是另一个view的子控件
    if (![self.menuView isDescendantOfView:self.view]) {
        [self.view addSubview:self.menuView];
    }
    else{
        
        
        [UIView animateWithDuration:0.3 animations:^{
            CGRect frame=self.menuView.frame;
            frame.size.height=0;
            self.menuView.frame=frame;
        } completion:^(BOOL finished) {
            [self.menuView removeFromSuperview];
            self.menuView=nil;
        }];
        
    
    }

}



//采用懒加载的形式加载下拉菜单
-(UIView *)menuView{
    if (_menuView==nil) {
        _menuView=[[UIView alloc]init];
        
        
        _menuView.backgroundColor=[UIColor blueColor];
        _menuView.frame=CGRectMake(0, 64, self.view.frame.size.width, 200);
        [self.view addSubview:_menuView];
    }
    return _menuView;
}
@end
